<template>
  <div class="box">
    <div class="loginbox">
      <div class="text">登录</div>
      <el-form label-width="100px">
        <el-form-item label="账户">
          <el-input type="text" v-model="admin" clearable style="width:220px"></el-input>
        </el-form-item>
        <el-form-item label="密码" style="color:black">
          <el-input type="password" v-model="password" clearable style="width:220px"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitLogin" style="margin-left:20px">登录</el-button>
          <el-button type="primary" @click="resetLogin">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
import axios from "axios";
export default {
  name: "MyLogin",
  mounted() {
    axios
      .get("http://127.0.0.1/manager_yang")
      .then((res) => {
        this.manageInfo = res.data;
        console.log(this.manageInfo);
      })
      .catch((err) => {
        console.log("获取数据失败" + err);
      });
  },
  data() {
    return {
      manageInfo: [],
      password: "",
      admin: "",
    };
  },
  methods: {
    submitLogin() {

      if (
        this.password == this.manageInfo[0].password || this.admin == this.manageInfo[0].admin
      ) {
        this.$router.push('/MyIndex')
      } else {
        alert("请输入正确的账号和密码")
      }
    },
    resetLogin(){
      this.admin = ''
      this.password = ''
    }
  },
};
</script>
<style scoped>
.box {
  position: absolute;
  top: 110px;
  left: 250px;
  height: 788px;
  width: 1400px;
  border: 5px solid #1e874c;
  background: url(../../assets/loginbg.jpg);
  background-size: contain;
}
.loginbox {
  height: 350px;
  width: 400px;
  margin: 150px 500px 0 500px;
  border: 1px solid #1e874c;
  background-color: rgba(255, 255, 255, 0.5);
}
.text {
  height: 60px;
  width: 400px;
  text-align: center;
  line-height: 60px;
  font-size: 26px;
  margin-bottom: 40px;
  background-color: #1e874c;
}
</style>